<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>行为日志</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab layui-tab-card">
            <table style="margin-top: 10px;" id="log-operate-table" lay-filter="user-table"></table>
        </div>
    </div>
</div>
</body>

<script type="text/html" id="log-bar">
    {{#if (d.logStatus == 0) { }}
    <button class="pear-btn pear-btn-sm pear-btn-success" lay-event="edit"><i class="layui-icon layui-icon-ok"></i>
        成功</button>
    {{# }else if(d.logStatus == 1){ }}
    <button class="pear-btn pear-btn-sm pear-btn-danger" lay-event="error"><i class="layui-icon layui-icon-help"></i>
        异常</button>
    {{# } }}
</script>

<script type="text/html" id="log-createTime">
    {{layui.util.toDateString(d.createTime,  "yyyy-MM-dd HH:mm:ss")}}
</script>

<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['table','form','jquery','element'],function () {
        let table = layui.table;
        let form = layui.form;
        let element = layui.element;

        let cols = [
            [
                {title: '模块', field: 'logModule', align:'center'},
                {title: '请求方式', field: 'logMethod', align:'center'},
                {title: '接口', field: 'logApi', align:'center'},
                {title: '浏览器', field: 'logBrowser', align:'center'},
                {title: '操作地址', field: 'logIp',align:'center'},
                {title: '操作系统', field: 'logSystem', align:'center'},
                {title: '访问时间', field: 'logOperator',templet:'#log-createTime', align:'center'},
                {title: '访问状态', toolbar: '#log-bar', align:'center', width:150}
            ]
        ]

        table.render({
            elem: '#log-operate-table',
            url: '/api/system/log/list',
            page: true ,
            cols: cols ,
            skin: 'line',
            request: {
                pageName: 'pageNo', // 页码的参数名称，默认：page
                limitName: 'limit' // 每页数据条数的参数名，默认：limit
            },
            //在请求头里面添加token
            headers:{"token":sessionStorage.token},
            // 重新规定成功的状态码为 200，table 组件默认为 0
            response: {
                statusCode: 200 
            },
            // 将原始数据解析成 table 组件所规定的数据格式
            parseData: function(res){
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.records //解析数据列表
                };
            },
            toolbar: false
        });
    })
</script>
</html>